package com.hd.trans.framework.tools;

import android.util.SparseArray;

/**
 * Author: yang
 * Date: 2018/11/13 15:47
 * Desc: App内通信事件
 */
public final class AppEvents {

    private AppEvents() { /* 不开放构造函数 */ }


    private static final String UNKNOWN_STR = "Unknown";//未知类型
    private static final int BEGIN = 100;

    public static final int LOG_IN = BEGIN + 1;  //登录
    public static final int LOG_OUT = BEGIN + 2;  //退出登录
    public static final int REFRESH_USER_INFO = BEGIN + 3;  //更新用户信息
    public static final int REFRESH_VIP_INFO = BEGIN + 4;  //刷新Vip信息

    public static final int PAY_RESULT = BEGIN + 5;  //支付结果
    public static final int COLLECTION_DELETE = BEGIN + 6;  //收藏删除
    public static final int COLLECTION_SHOW = BEGIN + 7;  //收藏记录显示
    public static final int HISTORY_DELETE = BEGIN + 8;  //历史删除

    public static final int PLAY_COMPLETE = BEGIN + 10;  //播放结束
//    public static final int USER_NICK_NAME_UPDATE = BEGIN + 11;  //昵称更新

    public static final int SHOW_COUPON = BEGIN + 20;  //显示优惠券


    public static final int REFRESH_ALI_TOKEN = BEGIN + 100;  //刷新ali识别token

//    public static final int ERROR_TOKEN = BEGIN + 200;  // token 错误

    public static final int NETWORK_CONNECT = BEGIN + 600;  // 网络连接

    public static final int GOTO_BACKGROUND = BEGIN + 300;  // app 转至后台
    public static final int GOTO_FOREGROUND = BEGIN + 310;  // app 转至前台


    public static String getEventDesc(int code) {

        if (EventDescs.indexOfKey(code) != -1) {
            return EventDescs.get(code);
        }
        return UNKNOWN_STR;
    }

    public static SparseArray<String> EventDescs = new SparseArray<>();

    static {
        EventDescs.clear();
        EventDescs.put(GOTO_BACKGROUND, "event_goto_background");
        EventDescs.put(GOTO_FOREGROUND, "event_goto_foreground");
        EventDescs.put(LOG_IN, "log_in");
        EventDescs.put(LOG_OUT, "log_out");
    }

}
